package com.example.tuike.mapper;

import com.example.tuike.entity.Feeds;
import org.apache.ibatis.annotations.*;
import org.mybatis.spring.annotation.MapperScan;

import java.util.List;

/*** @Author supersaiya
 * @Description TODO

 * @Date 2025/2/2 21:06

 * @Version 1.0*/

@Mapper
@MapperScan
public interface FeedsMapper {

    @Select("SELECT * FROM Feeds")
    List<Feeds> findAll();

    @Select("SELECT * FROM Feeds WHERE feedId = #{feedId}")
    Feeds findById(@Param("feedId") Integer feedId);

    @Insert("INSERT INTO Feeds (sourceUrl, title) VALUES ( #{sourceUrl}, #{title})")
    @Options(useGeneratedKeys = true, keyProperty = "feedId")
    void insert(Feeds feed);

    @Update("UPDATE Feeds SET title = #{title} WHERE feedId = #{feedId}")
    void update(Feeds feed);

    @Delete("DELETE FROM Feeds WHERE feedId = #{feedId}")
    void delete(@Param("feedId") Integer feedId);
}